package LeetCode;

import java.util.HashSet;
import java.util.Set;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}9:41
 */
public class LeetCode217 {
    //不加范围的双指针解法
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>(nums.length);
        for (int x: nums) {
            if (set.contains(x)) return true;
            set.add(x);
        }
        return false;
    }

    public static void main(String[] args) {
        int[] nums = {3,1};
        System.out.println(new LeetCode217().containsDuplicate(nums));
    }
}
